home *** CD-ROM | disk | FTP | other *** search
- #define DMABufferBase (Ptr) 0x61000000
-
- #define AMICSlotIER 0x50F26012
-
- #define AMICSoundOutDMA 0x50F14018
- #define AMICSoundInDMA 0x50F14014
-
- #define AMICCodecCtl0 0x50F14000
- #define AMICCodecCtl1 0x50F14001
- #define AMICCodecCtl2 0x50F14002
-
- #define kCommand 0x40 // Command bit, when in Awacs mode
- #define kExpand 0x80 // Expand bit, when in Awacs mode
-
- #define kHeadphonesInserted 0x08 // bit in AMICCodecStatus2
-
- #define AMICCodecStatus0 0x50F14004
- #define AMICCodecStatus1 0x50F14005
- #define AMICCodecStatus2 0x50F14006
-
- #define AMICPhase0 0x50F1400C
- #define AMICPhase1 0x50F1400D
- #define AMICPhase2 0x50F1400E
-
- #define AMICSndCtl0 0x50F14010
- #define kSndOutDMAEnable 0x01 // bit to enable/disable DMA sound out
- #define AMICSndCtl1 0x50F14011
-
- #define AMICSndBufSizeHi 0x50F14008
- #define AMICSndBufSizeLo 0x50F14009
-
- #define kBuf0Offset 0x00010000
- #define kBuf1Offset 0x00012000
-
- #define AMICVIADataB 0x50F00000 // used for a short delay...
-
- // Our interrupt vector bit - defined in Internal:Asm:DMAMgrEqu.a in SuperMario.
-
- #define hwAmicSOUT 9 // Sound Out
-
- #define kInstall 0 // for _DMAIntInstall
- #define kRemove 1
-
- #define kAwacsSignature 'JoeB' //JoeB
- #define hwAmicSOUT 9
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // Macros
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- // turn a byte count into a sample count (assuming 16 bit stereo)
- #define BytesToSamples(bytes) (bytes >> 2)
-
- // turn a sample count into a byte count (assuming 16 bit stereo)
- #define SamplesToBytes(samples) (samples << 2)
-
-
- // Can't spinloop on AMIC2, need the worst-case delay
-
- #if forPDMProto
- #define ProtoDelay \
- if (!(globals->AMIC3)) { \
- Delay(10, (long *)&globals->finalTicks); \
- *(unsigned char *)AMICCodecCtl0 = kCommand; \
- }
- #else
- #define ProtoDelay ;
- #endif
-
-
- // Write curR1 to Awacs.
- // (Register numbers (0,1,2,4) are pre-stuffed into hi nybble of shadow.)
-
- #define WRITE_AWACS_REG_1 \
- WaitExpandClear(globals); /* wait til it's safe */ \
- *(unsigned char *)AMICCodecCtl0 = kCommand; \
- *(unsigned char *)AMICCodecCtl1 = (curR1 >> 8); /* reg 1, [11:8] */ \
- *(unsigned char *)AMICCodecCtl2 = curR1; /* [7:0] */ \
- *(unsigned char *)AMICCodecCtl0 = kExpand | kCommand; /* Set Expand */ \
- ProtoDelay;
-
- // Write curR2 to Awacs.
- // (Register numbers (0,1,2,4) are pre-stuffed into hi nybble of shadow.)
-
- #define WRITE_AWACS_REG_2 \
- WaitExpandClear(globals); /* wait til it's safe */ \
- *(unsigned char *)AMICCodecCtl0 = kCommand; \
- *(unsigned char *)AMICCodecCtl1 = (curR2 >> 8); /* reg 2, [11:8] */ \
- *(unsigned char *)AMICCodecCtl2 = curR2; /* [7:0] */ \
- *(unsigned char *)AMICCodecCtl0 = kExpand | kCommand; /* Set Expand */ \
- ProtoDelay;
-
- // Write curR4 to Awacs.
- // (Register numbers (0,1,2,4) are pre-stuffed into hi nybble of shadow.)
-
- #define WRITE_AWACS_REG_4 \
- WaitExpandClear(globals); /* wait til it's safe */ \
- *(unsigned char *)AMICCodecCtl0 = kCommand; \
- *(unsigned char *)AMICCodecCtl1 = (curR4 >> 8); /* reg 4, [11:8] */ \
- *(unsigned char *)AMICCodecCtl2 = curR4; /* [7:0] */ \
- *(unsigned char *)AMICCodecCtl0 = kExpand | kCommand; /* Set Expand */ \
- ProtoDelay;
-
-
- // AMIC Control Macros
-
- // --------------
- // Macros for dealing with Sound DMA interrupts.
-
- #define CLEAR_SND_OUT_IF1 \
- *(unsigned char *)AMICSoundOutDMA |= 0x80
-
- #define CLEAR_SND_OUT_IF0 \
- *(unsigned char *)AMICSoundOutDMA |= 0x40
-
- #define CLEAR_SND_OUT_BUF_INTS \
- *(unsigned char *)AMICSoundOutDMA |= 0xC0
-
- #define CLEAR_UNDERRUN_INT \
- *(unsigned char *)AMICSoundOutDMA |= 0x20
-
- #define ENABLE_IF1_INT \
- *(unsigned char *)AMICSoundOutDMA |= 0x08
-
- #define DISABLE_IF1_INT \
- *(unsigned char *)AMICSoundOutDMA &= ~0x08
-
- #define SND_OUT_IF1 \
- ((*(unsigned char *)AMICSoundOutDMA) & 0x80)
-
- #define ENABLE_IF0_INT \
- *(unsigned char *)AMICSoundOutDMA |= 0x04
-
- #define DISABLE_IF0_INT \
- *(unsigned char *)AMICSoundOutDMA &= ~0x04
-
- #define SND_OUT_IF0 \
- ((*(unsigned char *)AMICSoundOutDMA) & 0x40)
-
- #define SND_OUT_UNDERRUN \
- ((*(unsigned char *)AMICSoundOutDMA) & 0x20)
-
-
- #define ENABLE_BUF_AND_UNDERRUN_INTS \
- *(unsigned char *)AMICSoundOutDMA |= 0x0E
-
- #define DISABLE_BUF_AND_UNDERRUN_INTS \
- *(unsigned char *)AMICSoundOutDMA &= ~0x0E
-
- // --------------
- // Macros to start/stop sound out DMA
-
- #define SND_OUT_DMA_ENABLE \
- *(unsigned char *)AMICSndCtl0 |= kSndOutDMAEnable
-
- #define SND_OUT_DMA_DISABLE \
- *(unsigned char *)AMICSndCtl0 &= ~kSndOutDMAEnable
-
- // --------------
- // Macro to see if sound out DMA is running
-
- #define SND_OUT_DMA_RUNNING \
- ( (*(unsigned char *)AMICSndCtl0) & kSndOutDMAEnable )
-
- // --------------
- // Macros to start/stop sound in DMA
-
- #define SND_IN_DMA_ENABLE \
- *(unsigned char *)AMICSndCtl1 |= 0x80
-
- #define SND_IN_DMA_DISABLE \
- *(unsigned char *)AMICSndCtl1 &= ~0x80
-
- // --------------
- // Macro to see if sound in DMA is running
-
- #define SND_IN_DMA_RUNNING \
- ( (*(unsigned char *)AMICSndCtl1) & 0x80 )
-
- // --------------
- // Macros to set the sample rate
-
- #define SET_RATE_44_1 \
- *(unsigned char *)AMICSndCtl0 = \
- (((*(unsigned char *)AMICSndCtl0) & 0xF9) | 0x04);
-
- #define SET_RATE_29_4 \
- *(unsigned char *)AMICSndCtl0 = \
- (((*(unsigned char *)AMICSndCtl0) & 0xF9) | 0x02);
-
- #define SET_RATE_22_05 \
- *(unsigned char *)AMICSndCtl0 = \
- ((*(unsigned char *)AMICSndCtl0) & 0xF9);
-
- #define SET_HW_RATE(rate) \
- *(unsigned char *)AMICSndCtl0 = \
- (((*(unsigned char *)AMICSndCtl0) & 0xF9) | rate);
-
- // --------------
- // Macros to get the sample rate
-
- #define GET_HW_RATE \
- (*(unsigned char *)AMICSndCtl0)
-
- #define RATE_IS_44_1 \
- ((*(unsigned char *)AMICSndCtl0) & 0x06) == 0x04
-
- #define RATE_IS_29_4 \
- ((*(unsigned char *)AMICSndCtl0) & 0x06) == 0x02
-
- #define RATE_IS_22_05 \
- ((*(unsigned char *)AMICSndCtl0) & 0x06) == 0x00
-
- // --------------
- // Misc Macros
-
- #define SET_OUTPUT_SUBFRAME_0 \
- *(unsigned char *)AMICSndCtl1 = \
- (((*(unsigned char *)AMICSndCtl1) & 0xC3) | 0x04)
-
- #define SET_BUF_SIZE(size) \
- *(unsigned char *)AMICSndBufSizeHi = (size >> 8); \ \
- *(unsigned char *)AMICSndBufSizeLo = size
-
- #define GET_BUF_SIZE_HI \
- *(unsigned char *)AMICSndBufSizeHi
-
- #define GET_BUF_SIZE_LO \
- *(unsigned char *)AMICSndBufSizeLo
-
- #define SET_BUF_SIZE_HI(size) \
- *(unsigned char *)AMICSndBufSizeHi = size;
-
- #define SET_BUF_SIZE_LO(size) \
- *(unsigned char *)AMICSndBufSizeLo = size;
-
- #define MATCH_BUF_SIZE(size) \
- ( (*(unsigned char *)AMICSndBufSizeHi == (unsigned char)(size >> 8)) && \
- (*(unsigned char *)AMICSndBufSizeLo == (unsigned char)size) )
-
- #define GET_DMA_BUF_BASE \
- 0x61000000
-